from django.contrib.auth.decorators import login_required


class LoginRequiredMixin(object):
    """验证用户是否登录"""
    @classmethod
    def as_view(cls, **initkwargs):
        """重写as_view()"""

        # 获取类视图as_view()后的结果
        view = super().as_view(**initkwargs)

        # login_required装饰器装饰结果
        return login_required(view)